<template>
	<div>
		<el-form :inline="true" :model="query" label-width="130px" size="small">
			<!-- 申请生成时间 -->
			<el-form-item>
				<el-date-picker v-model="createTime" unlink-panels type="datetimerange" :picker-options="pickerOptions"
					range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" align="left"
					format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
					:default-time="['00:00:00','23:59:59']" @change="dateChange"></el-date-picker>
			</el-form-item>
			<!-- 申请商城账号查询 -->
			<el-form-item class="query-form-item">
				<el-input v-model="query.content" placeholder="请输入用户昵称/号码" prefix-icon="el-icon-search"
					@keyup.enter.native="onSubmit" clearable></el-input>
			</el-form-item>
			<!-- 查询框 -->
			<el-form-item>
				<el-button type="primary" icon="el-icon-refresh" @click="onRest" size="small"></el-button>
				<el-button type="primary" icon="el-icon-search" @click="onSubmit" size="small">查询</el-button>
			</el-form-item>
		</el-form>
		<!-- table表单 -->
		<el-table ref="multipleTable" v-loading="loading" :data="tableData"
			:header-cell-style="{background:'#F4F4F5',color:'#606266'}" border>

			<el-table-column label="序号" type="index" width="80" align="center">
				<template scope="scope">
					<span>{{(query.currentPage - 1) * query.pageSize + scope.$index + 1}}</span>
				</template>
			</el-table-column>
			<el-table-column label="头像" prop="userpic" align="center" width="100">
				<template slot-scope="scope">
					<el-popover v-if="scope.row.userpic" placement="right" trigger="hover">
						<img :src="scope.row.userpic" style="width:400px;border-radius:3px;">
						<img slot="reference" :src="scope.row.userpic"
							style="max-height: 80px;max-width: 50px;border-radius:5px;">
					</el-popover>
					<el-popover v-else placement="right" trigger="hover">
						<img src="../../assets/image/appimage.png" style="width:400px;border-radius:3px;">
						<img slot="reference" src="../../assets/image/appimage.png"
							style="max-height: 80px;max-width: 50px;border-radius:5px;">
					</el-popover>

					<!-- <span v-else>-</span> -->
				</template>
			</el-table-column>
			<el-table-column label="用户昵称" prop="usernick" width="140" align="center">
				<template slot-scope="scope">
					<span v-if="scope.row.usernick !=null"> {{scope.row.usernick}}</span>

					<span v-else>{{scope.row.usermobile}}</span>
				</template>
			</el-table-column>
			<el-table-column label="手机号码" prop="usermobile" align="center" width="150" />
			<el-table-column label="企业名称" prop="enterprisename" align="center" />
			<el-table-column label="社会统一信用代码" prop="registrationnumber" align="center" />
			<el-table-column label="注册时间" width="180" :show-overflow-tooltip="true" align="center">
				<template slot-scope="scope">
					<i class="el-icon-time" v-if="scope.row.userregisttime!=null"></i>
					<span v-if="scope.row.userregisttime!=null">{{ scope.row.userregisttime | formatDateStr('yyyy-MM-dd hh:mm:ss') }}</span>
					<span v-else>无</span>
				</template>
			</el-table-column>
			<el-table-column label="操作" align="center" width="150" fixed="right">
				<template slot-scope="scope">
					<el-button type="primary" size="mini" @click.native="searchDetail(scope.$index, scope.row)">明细查询
					</el-button>

				</template>
			</el-table-column>
		</el-table>

		<el-pagination class="pagination-container" background :page-size="query.pageSize"
			@size-change="handleSizeChange" @current-change="handleCurrentChange"
			layout="total,sizes,prev, pager, next, jumper" :current-page="this.query.currentPage"
			:page-sizes="[5,10, 20, 30, 50]" :total="totalNumber"></el-pagination>
	</div>

</template>
<script>
	import { 
		getCapitalList,//获取列表	
	} from "../../api/fundsManagement";
	
	export default {
		data() {
			return {
				tableData: [], //列表集合
				createTime: [], //时间数组
				detailVisible: false, //新增弹窗
				pickerOptions: {
					//快速选择日期
					shortcuts: [{
							text: "最近一周",
							onClick(picker) {
								const end = new Date();
								const start = new Date();
								start.setTime(
									start.getTime() - 3600 * 1000 * 24 * 7
								);
								picker.$emit("pick", [start, end]);
							}
						},
						{
							text: "最近一个月",
							onClick(picker) {
								const end = new Date();
								const start = new Date();
								start.setTime(
									start.getTime() - 3600 * 1000 * 24 * 30
								);
								picker.$emit("pick", [start, end]);
							}
						},
						{
							text: "最近三个月",
							onClick(picker) {
								const end = new Date();
								const start = new Date();
								start.setTime(
									start.getTime() - 3600 * 1000 * 24 * 90
								);
								picker.$emit("pick", [start, end]);
							}
						},
						{
							text: "最近六个月",
							onClick(picker) {
								const end = new Date();
								const start = new Date();
								start.setTime(
									start.getTime() - 3600 * 1000 * 24 * 180
								);
								picker.$emit("pick", [start, end]);
							}
						}
					]
				},
				query: {
					currentPage: 1,
					pageSize: 5,
					startTime: "", //开始时间
					endTime: "", //结束时间
					content: "" //用户昵称
				},
				dataList: [],
				totalNumber: 0,
				loading: false,
				dataList: [],
				disabled: false,
				dialogTableVisible: false,
				dialogFormVisible: false,
				rejectData: [],
				reasons: "",
				formLabelWidth: '120px'
			}
		},
		methods: {
			/*日期选择事件*/
			dateChange(val) {
				if (val == null) {
					this.query.startTime = "";
					this.query.endTime = "";
				} else {
					this.query.startTime = val[0];
					this.query.endTime = val[1];
					this.query.currentPage = 1;
				}
				this.getList();
				// console.log(this.query);
			},


			// 列表数据获取
			getList() {
				this.loading = true;
				getCapitalList(this.query)
					.then(data => {
					
						if (data.code != 0) {
							this.$message.error(response.message);
							this.loading = false;
							return false;
						}
						this.tableData = data.data.list || []
						this.totalNumber = data.data.totalNumber || 0;
						setTimeout(() => {
							this.loading = false;
						}, 0.3 * 1000);
					})
					.catch(err => {
						this.loading = false;
						this.tableData = []
					})
			},
			
			//明细查询跳转页面至商城资金明细页面
			searchDetail(index,row){
				this.$router.push({path:"fundsDetail",query:row})
			
			},
			// 隐藏详情弹框
			hideDetailForm() {
				// 更改值
				this.detailVisible = !this.detailVisible;
				// this.formData={};
				return true;
			},
			//刷新
			onRest() {
				this.$router.push({
					path: ""
				});
				this.createTime = [],
					this.query = {
						currentPage: 1,
						pageSize: 5,
						startTime: "", //开始时间
						endTime: "", //结束时间
						content: ""
					};

				this.getList()
			},



			//查询
			onSubmit() {
				this.query.currentPage = 1;
				this.getList()
			},
			handleCurrentChange(val) {
				this.query.currentPage = val;
				this.getList()
			},
			handleSizeChange(val) {
				this.query.pageSize = val;
				this.getList()
			},
		},

		mounted() {

		},
		created() {
			this.getList()
		}

	}
</script>
